package com.tedu.pj.common.advisor;

import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

/**
 * <p>
 *
 * </p>
 *
 * @author Song
 * @since 2020/10/22
 */
@Component
public class LogAdvisor extends StaticMethodMatcherPointcutAdvisor {
    public LogAdvisor(){
        setAdvice(new LogAdvice());
    }

    @Override
    public boolean matches(Method method, Class<?> targetClass) {
        try {
            Method declaredMethod = targetClass.getDeclaredMethod(method.getName(), method.getParameterTypes());
            return declaredMethod.getName().equals("sendMail");
        }catch (Exception e){
            return false;
        }

    }
}
